<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>网格布局</title>
  </head>
  <body>
    <style>
      body {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        justify-content: center;
        align-items: center;
      }
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }
      .item {
        display: flex;
        justify-content: center;
        align-items: center;
      }
      .item1 {
        grid-column-start: 1;
        grid-column-end: 4;
        background-color: #40407a;
      }
      .item2 {
        grid-column-start: 1;
        grid-column-end: 2;
        grid-row-start: 2;
        grid-row-end: 5;
        background-color: #706fd3;
      }
      .item3 {
        background-color: #f7f1e3;
      }
      .item4 {
        background-color: #34ace0;
      }
      .item5 {
        background-color: #33d9b2;
      }
      .item6 {
        background-color: #ff5252;
        grid-column-start: 2;
        grid-column-end: 4;
      }
      .item7 {
        background-color: #ff793f;
      }
      .item8 {
        background-color: #ffb142;
      }
      .item9 {
        background-color: #84817a;
      }

      .item10 {
        background-color: #57606f;
      }
      .main {
        width: 80%;
        height: 500px;
        border: 1px solid;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
      }
    </style>
    <div class="main">
      <div class="item item1">1</div>
      <div class="item item2">2</div>
      <div class="item item3">3</div>
      <div class="item item4">4</div>
      <div class="item item5">5</div>
      <div class="item item6">6</div>
      <div class="item item7">7</div>
      <div class="item item8">8</div>
      <div class="item item9">9</div>
      <!-- <div class="item item10">10</div> -->
    </div>
  </body>
</html>
